<template>
  <div>
    <el-menu

      class="el-menu-vertical-demo"
      @open="handleOpen"
      @close="handleClose"
      background-color="#545c64"
      text-color="#fff"
      active-text-color="#ffd04b">

      <el-submenu :index="index+''" v-for="(menu, index) in menulist" :key="index">
        <template slot="title">
          <i :class="menu.icon"></i>
          <span>{{menu.menuName}}</span>
        </template>
        <el-menu-item-group>
           <el-menu-item v-for="(submenu, index) in menu.children" :key="index" :index="index+''" @click="handlerRouter(submenu.href)">{{submenu.menuName}}</el-menu-item>
        </el-menu-item-group>
      </el-submenu>
    </el-menu>
  </div>
</template>

<script>
export default {
  data() {
    return {
        menulist: JSON.parse(sessionStorage.getItem("menuList")),
    };
  },
  methods: {
    handlerRouter(url){
        this.$router.push(url);
    },
     handleOpen(key, keyPath) {
        console.log(key, keyPath);
      },
      handleClose(key, keyPath) {
        console.log(key, keyPath);
      }
  },
};
</script>
